<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') ?>
<title>WMS—<?= $sf_response->getTitle() ?></title>
<?php use_stylesheet('/sf/sf_admin/css/main') ?>

<div id="sf_admin_container">

<h1>Create TallyIn</h1>

<div id="sf_admin_header">
</div>

<div id="sf_admin_content">

<?php echo form_tag('tallyin/create', array(
  'id'        => 'sf_admin_edit_form',
  'name'      => 'sf_admin_edit_form',
  'multipart' => true,
)) ?>
    
<fieldset id="sf_fieldset_none" class="">

<div class="form-row">
  <label for="tally_in_tallyincode">TallyIn Number:</label>  <div class="content">

<!--Tien-->
  <?php $default = CommonValues::GenerateAutoNumber('TALLYIN', NULL, 'TI', 'm')   ?>

   <input name="tallyincode" id="tallyincode" value="<? echo $default; ?>" size="15" disabled="disabled" type="text">
   </div>
</div>

<div class="form-row">
  <label for="tally_in_type">Type:</label>
  <div class="content">

  <select name="tally_in[type]" id="tally_in_type" class="TALLYOUTTYPE" onchange="GenerateTallyin()">
        <option value="0" selected="1">Supplier</option>
        <option value="1">Project</option>
        <option value="2">Production</option>
        <option value="3">Service</option>
      </select>

  </div>
</div>

<div id="tally_number">
<div class="form-row">

  <label for="tally_in_type">PO Number:</label>
  <div class="content">

  <select name="tally_in[tallyno]" id="tally_in_tallyno" class="tally_in_tallyno" >
      <?
        $c = new Criteria();
        $c->addDescendingOrderByColumn(POPeer::PONO);
        $c->add(POPeer::APPROVALSTATUS , CommonValues::$gMRApprovalStatus['key']['Approved']);
        $c->add(POPeer::RECEIVEDSTATUS , CommonValues::$gPOReceivedStatus['key']['Fully Received'], Criteria::NOT_EQUAL);
        $c->add(POPeer::RECEIVEDSTATUS , CommonValues::$gPOReceivedStatus['key']['Revised'], Criteria::NOT_EQUAL);
      $poList = POPeer::doSelect($c);

      foreach ($poList as $po)
      {
          $id = $po->getId();
          echo "<option value='$id'>";
          echo $po->getPono().":".$po->getSupplier();
          echo "</option>";
      }
      ?>
  </select>

  </div>


</div>

</div>

</fieldset>

<?php
echo link_to_remote('', array('update' => 'list_component',
  'url' => 'component/listAjax',
  'loading' => visual_effect('appear', 'indicator'),
  'complete' => visual_effect('fade', 'indicator'). visual_effect('highlight', 'list_component'),
  'position' => 'bottom',
));
?>
<script type="text/javascript">
function GenerateTallyin(){
    var tally = $("tally_in_type");
    var type = tally.options[tally.selectedIndex].value;
    var link = '<?php echo url_for('tallyin/TallyinNoAjax') ?>';
    new Ajax.Updater('tally_number', link + '?type='+ type);
}
</script>

<ul class="sf_admin_actions">

  <li><?php echo submit_tag(__('continue'), array (
  'name' => 'continue',
  'class' => 'sf_admin_action_save',
)) ?></li>
</ul>
    
</form>